﻿using System;

namespace $RootNamespace$
{

    // $IState$ 
    interface $IState$
    {
        void $Handle$($Context$ context);
        string ThisState { get; }

    }


    // $Context$ 
    class $Context$
    {
        static public void Test()
        {
            // Setup context in a $IState$ 
            $Context$ c = new $Context$(new $ConcreteStateA$());

            // Client requests, which toggles $RootNamespace$ 
            c.Request();
            c.Request();
            c.Request();

        }

        // Constructor 
        public $Context$($IState$ $RootNamespace$)
        {
            this.CurrentState = $RootNamespace$;
        }

        // Property 
        public $IState$ CurrentState {get; set;}

        public void Request()
        {
            Console.WriteLine("Request on " +  CurrentState.ThisState);
            CurrentState.$Handle$(this);
        }
    }


    // $ConcreteStateA$ 
    class $ConcreteStateA$ : $IState$
    {
        public void $Handle$($Context$ context)
        {
            context.CurrentState = new $ConcreteStateB$();
        }

        public string ThisState { get { return "$ConcreteStateA$"; } }
    }

    // $ConcreteStateB$ 
    class $ConcreteStateB$ : $IState$
    {
        public void $Handle$($Context$ context)
        {
            context.CurrentState = new $ConcreteStateC$();
        }
        public string ThisState { get { return "$ConcreteStateB$" ; }}
    }

    // $ConcreteStateC$ 
    class $ConcreteStateC$ : $IState$
    {
        public void $Handle$($Context$ context)
        {
            context.CurrentState = new $ConcreteStateA$();
        }
        public string ThisState { get { return "$ConcreteStateC$" ; }}
    }

}